<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    	<meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>iRestauranting - Restaurante <?php
            echo $_GET['search_resto'];
                ?></title>
		<link rel="icon" href="img/favicon.ico" type="image/x-icon" >
    	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <!-- Magnific Popup core CSS file -->
    	<link rel="stylesheet" href="css/magnific-popup.css">
        <link rel="stylesheet" media="all" href="css/irestauranting.css" />
        <link rel="stylesheet" media="all" href="css/tabs.css" />
    	<link rel="stylesheet" media="screen and (max-width: 1023px)" href="css/irestauranting_tablet.css" />
        <link rel="stylesheet" media="screen and (max-width: 1023px)" href="css/tabs_tablet.css" />
        <link rel="stylesheet" type="text/css" href="css/menu.css" >
        <!--<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>-->
		<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
        <meta name="description" content="Informe detallado de la reputación online del restaurante <?php echo $_GET['search_resto'];?>" >
</head>

<body>
	
	<div id="container">
        <div id="resto_header">
        	<div id="header-center">
                <div style="float:left">
                	<a href="index.html"><img src="img/LogoHome.png" /></a>
                </div>
                 <div style="margin-left:30px;float:left">
                 	<img src="img/barra_header.png" />
                 </div>
                 <div style="margin-top:20px;margin-left:30px;float:left;">
                 	<a style="text-decoration: none;"  href="como_funciona.html"><span style="color:#FFF" class="texto_span_16_bold">Cómo funciona</span></a>
                 </div>
                 <div style="margin-left:30px;float:left">
                 	<img src="img/barra_header.png" />
                 </div>
                 <div  style="margin-top:20px;margin-left:30px;float:left">
                 	<a style="text-decoration: none;" href="que_te_ofrecemos.html"><span style="color:#FFF" class="texto_span_16_bold">Qué te ofrecemos</span></a>
                 </div>
                 <div style="margin-left:30px;float:left">
                 	<img src="img/barra_header.png" />
                 </div>
                 <div  style="margin-top:20px;margin-left:30px;float:left">
                 	<a id="contact_form_link" style="text-decoration: none;" href="#test-popup"><span style="color:#FFF" class="texto_span_16_bold">Contacto</span></a>
                 </div>
             	
                 <div  id="div_login" style="margin-top:0px;float:right"></div>
             </div>
         </div>
         <div id="separador_header">
         </div>	
         <div style="clear:both" ></div>
         <div id="container_not_found">
         	<span style="text-align:center">
            <p>No se ha encontrado ningún restaurant con el nombre <b><?php echo $_GET['search_resto']; ?></b> en nuestra base de datos de restaurantes</p>
            <p>Si quieres que aparezca en iRestauranting, <a id="contact_form_link" class="texto_span_orange_18" href="#test-popup">contacta con nosotros</a></p></span>
            
            <img  src="img/esclavo.jpg" />
        </div>
        <div id="container_titulo_resto">
            	<div id="titulo_resto" class="titulo_resto" >
                	
                </div>
                
				
                <div id="adress_resto" class="adress_resto">
                	
                </div>              	
				
         </div>
         <br/>
         <div id="tabs">
         	<a style="text-decoration: none;" href="javascript:click_tab('tab_dashboard','<?php echo $_GET['id_resto']; ?>',null);">
                <div class="tab_15">
                </div>
                <div id="tab_dashboard"  class="tab" >
             		<img style="height:40px;vertical-align:middle"  src="img/dashboard_tab.png" />
                    <span class="texto_span_orange_18">General</span>
                </div>
            </a>
            <a style="text-decoration: none;" href="javascript:click_tab('tab_opiniones','<?php echo $_GET['id_resto']; ?>',null);">
                <div id="tab_opiniones" style="background-color:#414042;" class="tab">
                    <img style="height:40px;vertical-align:middle" src="img/opiniones_tab_off.png" />
                    &nbsp;<span style="color:#CCC;text-decoration:none" class="texto_span_orange_18" >Opiniones</span>
                </div>
            </a>
            <div id="filtros_fechas">
            </div>
         </div>
         <div style="clear:both" ></div>
         
         <div id="container_plantilla_resto">
         	
            <div id="resto_scoring">
            	<div id="scoring">
                	
                </div>
                <a href="#presencia">
					<div class="container_categoria">
						<div class="container_icon_categorio">						
								<img src="img/Presencia.png" />						
						</div>
						<div id="container_valoracion_presencia" class="container_valoracion_categoria">
						
						</div>
					</div>
				</a>
				<a href="#opiniones">
					 <div  class="container_categoria">
						<div class="container_icon_categorio">
							<img src="img/Opiniones.png" />
						</div>
						<div id="container_valoracion_opiniones" class="container_valoracion_categoria">
							
						</div>
					</div>
                </a>
				<a href="#actividad">
					 <div  class="container_categoria">
						<div class="container_icon_categorio">
							<img src="img/Actividad.png" />
						</div>
						<div id="container_valoracion_actividad" class="container_valoracion_categoria">
						
						</div>
					</div>
				</a>
            </div>
            <div id="resto_graph">
            	<div id="container_grafica">
                </div>
                <div class="resumen_categoria">
                	
            		Posicionado en el puesto <span id="num_ranking" class="highlight_resumen_categoria"></span> de los <span id="cont_rest" class="highlight_resumen_categoria"></span> restaurantes en <span id="txt_city_posicion" ></span>
					
            	</div>
                <div class="resumen_categoria">
            		En los últimos <span id="nro_dias"></span> días se han escrito  <span id="irest_var_posts" class="highlight_resumen_categoria"></span> opiniones nuevas sobre 
tu restaurante
            </div>
            <div id="resumen_redes_sociales" class="resumen_categoria">
            	
            </div>
            </div>
            <div style="clear:both" />
            <br>
            <div class="container_titulo_tematica">
            	<div class="titulo_categoria">
            		Indicador Global
                </div>
          	</div>
            <div id="container_global_scoring">
            	<div class="column_left">
                	<div id="list_categorias" class="resumen_indicador_graph">
                		<span id="ini_txt_city_categorias" ></span><span id="txt_city_categorias" ></span><span id="end_txt_city_categorias" ></span>
                	</div>  
                        
                    <div id="graph_ranking_category">
                	</div>
                    <img style="margin-bottom:10px;" src="img/separador_450.png" />
                    <br/>
                    <div id="desc_rest_cercanos" class="resumen_indicador_graph">
                		
                	</div>
                    <div id="map">
                	</div>
                    
                </div>
                
            	  <div class="column_right">
                	<div id="column_best_worst" style="float:left;position:relative">
                	
                    </div>
                  
                     <img class="separador_370" src="img/separador_450.png" />
                    <br/>
                    <br/>
                	<div class="resumen_indicador_graph">
                		Los restaurantes más valorados de tu zona
                	</div>
                	<div id="list_restos" style="position:relative;float:left">
                    	
                    </div>
                   
                </div>
                
            </div>
         </div>
          <br>
          <div style="clear:both" ></div>
		<br>
		<a name="presencia"></a>
		<div class="container_titulo_tematica">
			<div class="titulo_categoria">
				Presencia
			</div>
		</div>
         <div id="container_global">
         	<div class="texto_22">En qué canales está presente tu restaurante...</div>
            <div id="container_canales" class="container_canales">
            	<div class="line_canales">
                	<div class="canal">
                        <div id="channel_web" class="canal_thumbail">
                            <img src="img/icon_www_off.png" />
                        </div>
                        <div class="descripcion_canal">
                            Tu web
                        </div>
                    </div>
                    <div  class="canal">
                        <div id="channel_yelp" class="canal_thumbail">
                            <img src="img/icon_yelp_off.png" />
                        </div>
                        <div class="descripcion_canal">
                            Yelp
                        </div>
                    </div>
                    <div  class="canal">
                        <div id="channel_tripadvisor" class="canal_thumbail">
                            <img src="img/icon_tripadvisor_off.png" />
                        </div>
                        <div class="descripcion_canal">
                            TripAdvisor
                        </div>
                    </div>
                    <div  class="canal">
                        <div id="channel_eltenedor" class="canal_thumbail">
                            <img src="img/icon_eltenedor_off.png" />
                        </div>
                        <div class="descripcion_canal">
                            El Tenedor
                        </div>
                    </div>
                    <div  class="canal">
                        <div id="channel_salir" class="canal_thumbail">
                            
                        </div>
                        <div class="descripcion_canal">
                            Salir
                        </div>
                    </div>
                </div>
                <div class="line_canales">
                    <div class="canal">
                        <div id="channel_restalo" class="canal_thumbail">
                            <img src="img/icon_restalo_on.png" />
                        </div>
                        <div class="descripcion_canal">
                            Restalo
                        </div>
                     </div>
                     <div class="canal">
                        <div id="channel_atrapalo" class="canal_thumbail">
                            <img src="img/icon_atrapalo_off.png" />
                        </div>
                        <div class="descripcion_canal">
                            Atrapalo
                        </div>
                    </div>
                     <div class="canal">
                        <div id="channel_bcnrestaurantes" class="canal_thumbail">
                            <img src="img/icon_11870_off.png" />
                        </div>
                        <div class="descripcion_canal">
                            11870.COM
                        </div>
                     </div>
                     <div class="canal">
                         <div id="channel_facebook" class="canal_thumbail">
                           
                        </div>
                        <div class="descripcion_canal">
                            Facebook
                        </div>
                     </div>
                     <div class="canal">
                         <div id="channel_twitter" class="canal_thumbail">
                            <img src="img/twitter_logo_on.png" />
                        </div>
                        <div class="descripcion_canal">
                            Twitter
                        </div>
                    </div>
                </div>
                <div id="canales_comprados" class="line_canales" style="display:none">
                		<div class="canal">
                        	<div id="channel_web" class="canal_thumbail">
                            	<a target="new" id="img_foursquare_channel">
                            		<img  src="img/icon_foursquare_on.png" />
                                </a>
                        	</div>
                        	<div class="descripcion_canal">
                            	Foursquare
                        	</div>
                    	</div>
                </div>
                <div class="texto_18">Si tu restaurante se encuentra en alguno de los canales y no lo hemos detectado, <a id="contact_form_link2" class="texto_span_orange_18" href="#test-popup">contacta con nosotros</a></div>
                <br style="clear:both" />
            </div>
         </div>
        <br>
        <div style="clear:both"></div>
		<br>
		<a name="opiniones"></a>
		<div class="container_titulo_tematica">
			<div class="titulo_categoria">
				Opiniones
			</div>
		</div>
        <div id="container_global">
        	<div class="texto_22">Valoración de opiniones por categoría</div>
            <div id="reviews_by_category" style="height:180px"></div>
            <div class="texto_22">Análisis de sentimiento de las opiniones</div>
            <div id="reviews_sentimental" style="height:180px"></div>
        </div>
        <br>
        <div style="clear:both"></div>
		<br>
		<a name="actividad"></a>
		<div class="container_titulo_tematica">
			<div class="titulo_categoria">
				Actividad
			</div>
		</div>
        <div class="container_actividad">
         	 	<div class="texto_22">Dónde has recibido más opiniones?</div>
                <div id="ranking_reviews" style="height:260px"></div>
         </div>
        <div id="container_global">
            <div class="column_left_75">
                	<div class="resumen_indicador_graph">
                		Evolución de fans en Facebook y posts por día
                	</div>  
        			<div id="facebook_post_by_day"></div>
                     <img style="margin-top:10px;margin-bottom:10px;" src="img/separador_450.png" />
                     <br>
                     <br>
                    <div class="resumen_indicador_graph">
                		Evolución de followers en Twitter y mentions por días
                	</div>
                    
                    <div id="twitter_mentions_by_day">
                	</div>
                    <div id="foursquare_module_left" style="display:none;">
                    	<img style="margin-top:10px;margin-bottom:10px;" src="img/separador_450.png" />
                     	<br>
                     	<br>
                    	<div class="resumen_indicador_graph">
                			Valoración en Foursquare y número de checkins por día
                		</div>
                    
                    	<div id="foursquare_checkins_by_day">
                		</div>
                    </div>
             </div>
             <div class="column_right_25">
                	<div class="resumen_indicador_graph">
                		Impacto social en Facebook 
                	</div>  
                    <div id="facebook_stats_likes">
                        <div class="container_fan_activo">
                            <div class="container_fan_picture">
                                <img src="img/facebook_like.png" width="50px" height="50px" />
                            </div>
                            <div id="facebook_num_likes" class="container_fan_texto">
                            </div>
                        </div>
                        <div class="container_fan_activo">
                            <div class="container_fan_picture">
                                <img src="img/facebook_comment.png" width="50px" height="50px" />
                            </div>
                            <div id="facebook_num_comments" class="container_fan_texto">
                                <b>0</b> Comentarios
                            </div>
                        </div>
                        <div class="container_fan_activo">
                            <div class="container_fan_picture">
                                <img src="img/facebook_share.png" width="50px" height="50px" />
                            </div>
                            <div id="facebook_num_shares" class="container_fan_texto">
                                <b>0</b> Compartidos
                            </div>
                        </div>
                    </div>
   					 <img style="margin-top:10px;margin-bottom:10px;" src="img/separador_150.png" />
                     <br>
                     <br>
                     <div class="resumen_indicador_graph">
                		Followers de Twitter más activos 
                	</div> 
                    <div id="twitter_followers"> 
                        <div id="container_fan1" class="container_fan_activo">
                      
                        </div>
                        <div id="container_fan2" class="container_fan_activo">
                      
                        </div>
                        <div id="container_fan3" class="container_fan_activo">
                      
                        </div>
                    </div>
                    <div id="foursquare_module_right" style="display:none;">
                    	<img style="margin-top:10px;margin-bottom:10px;" src="img/separador_150.png" />
                     	<br>
                     	<br>
                     	<div class="resumen_indicador_graph">
                			El Mayor del restaurante 
                		</div> 
                    	<div id="foursquare_mayor"> 
                        	<div id="container_foursquare_mayor" class="container_fan_activo">                      
                        	</div>
                    	</div>
                    </div>
             </div>
        </div>
        <div id="test-popup" class="white-popup mfp-hide">
  			<form id="form_contact">
                <div id="resumen_envio" class="resumen_indicador_graph">
                            Contáctanos
                </div>  
                
                <div>
                    <span class="texto_form">Nombre:</span>
                    
                    <input style="display: inline-block;" type="text" name="name" id="name" size="40" />
                </div>
                <div>
                    <span class="texto_form">E-Mail:</span>
                    <input style="display: inline-block;" type="text" name="email" id="email" size="40" />
                </div>
                <div >
                    <span class="texto_form">Comentario:</span>
                    <textarea rows="10" cols="39" name="message" id="message"></textarea>
                </div>
                <div style="width:100%;">
            		<a id="submitButtonId"><img style="display: block;margin: 0 auto;cursor:pointer;" src="img/enviar.png" /></a>
            	</div>
                
            </form>
		</div>
		
		<div id="opiniones-popup" class="white-popup mfp-hide">
  			<form id="form_contact">
                <div id="resumen_envio" class="resumen_indicador_graph">
                            Si quieres ver las opiniones de tu restaurante en iRestauranting contacta con nosotros para conseguir una versión Premium
                </div>  
                
                <div>
                    <span class="texto_form">Nombre:</span>
                    
                    <input style="display: inline-block;" type="text" name="name" id="name" size="40" />
                </div>
                <div>
                    <span class="texto_form">E-Mail:</span>
                    <input style="display: inline-block;" type="text" name="email" id="email" size="40" />
                </div>
                <div >
                    <span class="texto_form">Comentario:</span>
                    <textarea rows="10" cols="39" name="message" id="message"></textarea>
                </div>
                <div style="width:100%;">
            		<a id="submitButtonId"><img style="display: block;margin: 0 auto;cursor:pointer;" src="img/enviar.png" /></a>
            	</div>
                
            </form>
		</div>  
        <br style="clear:both" /> 
     </div>
    <div id="container_plantilla_opiniones">
       
       <div style="height:700px;">
        	<div style="position:absolute;top:50%;left:50%;margin:-40px 0 0 -40px;" />
        		<img src="img/spinner.gif" />
            </div>
       </div>
    </div>
	 <div style="clear:both" ></div>
	 <div id="separador_footer">
     </div>
	 <div id="resto_footer">
		<div id="header-center">
			<div style="display:inline;float:left;width:100%;text-align:center;" >
            
            <div style="margin-top:15px;display:inline;float:left;" >
                <a href="terminos.html">
                    <span style="color:#FFF" class="texto_span_16_bold">Términos y condiciones</span>
                </a>
                &nbsp;-&nbsp;
                <a href="privacidad.html">
                    <span style="color:#FFF" class="texto_span_16_bold">Política de Privacidad</span>
                </a>
            </div>
            <div style="display:inline;float:right;" >
                <a target="_new" href="https://www.facebook.com/pages/IRestauranting/381455768647705?fref=ts">
                    <img  src="img/facebook_circle_color.png"  />
                </a>
                <a target="_new" href="https://twitter.com/iRestauranting">
                    <img src="img/twitter_circle_color.png"  />
                </a>
            </div>
        </div>			
		 </div>
	 </div>
	<!--
     <footer id="resto_footer"><br></footer>
	-->
	 
    <script src="js/jquery-1.9.1.js"></script>  
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
    <script src="js/jquery.dropdownPlain.js" type="text/javascript"></script>
	<script>
    $(document).ready(function () {
			
			 $.getJSON("login/user_management.php?check_login=1",
			 	function(data)
				{
					
					if(data.logged == true){
						var htmlMenu = "<ul class=\"user\"><li style=\"height:60px\"><a class=\"first_level\" id=\"login_form_link\"><span  id=\"login_text\" style=\"color:#FFF\" class=\"texto_span_16_bold\">" + data.username_complete + "</span>&nbsp;<img width=\"10px\" height=\"10px\" src=\"img/arrow_down.png\" /></a><ul class=\"sub_menu\"><li><a href=\"#\" >Mis Restaurantes</a></li>";
						
						for(var i=0;i < data.restaurants.length; i++)
							htmlMenu += "<li ><a href=\"home_resto.php?search_resto=" + encodeURIComponent(data.restaurants[i].desc_resto) + "&id_resto=" +data.restaurants[i].id_resto + "&intervalo=30d\" >&nbsp;&nbsp;" + data.restaurants[i].desc_resto + "</a></li>";
						
						htmlMenu += "<li><a href=\"login/modify_user.php\" >Mi Perfil</a></li>";	
						htmlMenu += "<li><a href=\"javascript:salir_sesion()\" >Salir</a></li></ul></li></ul>";		
						
						$("#div_login").html(htmlMenu);
						dropdownmenu_user();
						
					}
					else{
						$("#div_login").html("<ul style=\"margin-top:20px\"><li><a id=\"login_form_link\" href=\"login/login.html\"><span id=\"login_text\" style=\"color:#FFF\" class=\"texto_span_16_bold\">Entrar</span></a></li></ul>");
						$("#private_separator").css("visibility","hidden");
					}
					
				}
				);	
		});	
    </script>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=true"></script>   
    <script type="text/javascript">
    
    var intervalo_fechas = '<?php echo $_GET['intervalo']; ?>';
    var id_resto = '<?php echo $_GET['id_resto']; ?>';
    var mail = '<?php echo isset($_GET['mail']) ? $_GET['mail'] : 0 ?>';
	var campaign = 	'<?php echo isset($_GET['camp']) ? $_GET['camp'] : 0 ?>';
	var opiniones =  '<?php echo isset($_GET['opiniones']) ? $_GET['opiniones'] : 0 ?>';
	
    $(function () {
        if(id_resto.length == 0){
            $("#container_plantilla_resto").css("display","none");
            $("#container_not_found").css("display","block");
        }
		if(mail==1){
			var url = "contact/register_events.php?id_resto=" + id_resto + "&id_campaign=" + campaign;
			
			$.ajax({
				type: "POST",
				url: url					   
			});
		}
		if(opiniones==1){
			click_tab('tab_opiniones','<?php echo $_GET['id_resto']; ?>',null);
		}
    });
    $(function () {
        $.getJSON('metrics/fresh_scoring.php?id_resto=' + id_resto + '&intervalo=' + intervalo_fechas.toUpperCase() + '&type=IRESTAURANTING_GENERAL', function(JSONresult) {
                    $('#titulo_resto').text(JSONresult.description);
                    $('#scoring').text(String(JSONresult.irest_scoring).replace(".",","));
                    $('#adress_resto').text(JSONresult.address.replace(", España",""));
                    $('#num_ranking').text(JSONresult.num_ranking);
                    $('#cont_rest').text(JSONresult.cont_rest);
                    $('#irest_var_posts').text(JSONresult.irest_var_posts);
					$('#nro_dias').text(intervalo_fechas.replace("d",""));
                    $('#desc_rest_cercanos').html("Restaurantes cercanos a <br/><i>\"" + JSONresult.description + "\"</i>");
                    
                    var htmlFiltros = "";
                    
                    if(intervalo_fechas == '7d')
                        htmlFiltros += "<img width=\"50px\" height=\"30px\" src=\"img/filter_7d_on.png\" />";
                    else
                        htmlFiltros += "<a href=\"home_resto.php?id_resto=<?php echo $_GET['id_resto']; ?>&search_resto=<?php echo $_GET['search_resto']; ?>&intervalo=7d\"><img width=\"50px\" height=\"30px\" src=\"img/filter_7d.png\" /></a>";
                    if(intervalo_fechas == '15d')
                        htmlFiltros += "<img width=\"50px\" height=\"30px\" src=\"img/filter_15d_on.png\" />";
                    else
                        htmlFiltros += "<a href=\"home_resto.php?id_resto=<?php echo $_GET['id_resto']; ?>&search_resto=<?php echo $_GET['search_resto']; ?>&intervalo=15d\"><img width=\"50px\" height=\"30px\" src=\"img/filter_15d.png\" /></a>";
                    if(intervalo_fechas == '30d')
                        htmlFiltros += "<img width=\"50px\" height=\"30px\" src=\"img/filter_30d_on.png\" />";
                    else
                        htmlFiltros += "<a href=\"home_resto.php?id_resto=<?php echo $_GET['id_resto']; ?>&search_resto=<?php echo $_GET['search_resto']; ?>&intervalo=30d\"><img width=\"50px\" height=\"30px\" src=\"img/filter_30d.png\" /></a>";
                    $('#filtros_fechas').html(htmlFiltros);
                    
                    var htmlStr = "Tienes ";
                    var followers_twitter = JSONresult.irest_var_followers_twitter;
                    var fans_facebook = JSONresult.irest_var_fans_facebook;
                    
                    if(followers_twitter != null) 
                        htmlStr += "<span class=\"highlight_resumen_categoria\">" + followers_twitter + "</span> nuevos seguidores en Twitter ";
                    if(followers_twitter != null && fans_facebook != null)
                        htmlStr += " y ";
                    if(fans_facebook != null)
                        htmlStr += "<span class=\"highlight_resumen_categoria\">" + fans_facebook + "</span> nuevos fans en Facebook ";
                    if(followers_twitter == null && fans_facebook == null)
                        htmlStr = "No hemos detectado cuenta de Twitter ni Faceboook de tu restaurante";
                    $('#resumen_redes_sociales').html(htmlStr);
                    
                    // PRESENCIA
                    htmlStr = "<span class=\"nombre_categoria\">Presencia</span><br>";
                    htmlStr += "<span class=\"valoracion_categoria\">" + JSONresult.irest_presence + "</span>&nbsp;";
                    if(JSONresult.irest_presence_var > 0)
                        htmlStr += "<img src=\"img/tendencia_pos.png\" />";
                    else
                        if(JSONresult.irest_presence_var == 0)
                            htmlStr += "<img src=\"img/tendencia_igual.png\" />";
                        else
                            htmlStr += "<img src=\"img/tendencia_neg.png\" />";
                    $('#container_valoracion_presencia').html(htmlStr);
                    
                    // OPINIONES
                    var htmlStr = "<span class=\"nombre_categoria\">Opiniones</span><br>";
                    htmlStr += "<span class=\"valoracion_categoria\">" + JSONresult.irest_opinions + "</span>&nbsp;";
                    if(JSONresult.irest_opinions_var > 0)
                        htmlStr += "<img src=\"img/tendencia_pos.png\" />";
                    else
                        if(JSONresult.irest_opinions_var == 0)
                            htmlStr += "<img src=\"img/tendencia_igual.png\" />";
                        else
                            htmlStr += "<img src=\"img/tendencia_neg.png\" />";
                    $('#container_valoracion_opiniones').html(htmlStr);
                    
                    // ACTIVIDAD
                    var htmlStr = "<span class=\"nombre_categoria\">Actividad</span><br>";
                    htmlStr += "<span class=\"valoracion_categoria\">" + JSONresult.irest_activity + "</span>&nbsp;";
                    if(JSONresult.irest_activity_var > 0)
                        htmlStr += "<img src=\"img/tendencia_pos.png\" />";
                    else
                        if(JSONresult.irest_activity_var == 0)
                            htmlStr += "<img src=\"img/tendencia_igual.png\" />";
                        else
                            htmlStr += "<img src=\"img/tendencia_neg.png\" />";
                    $('#container_valoracion_actividad').html(htmlStr);
                    
                    // ¿TIENE WEB?
                    if(JSONresult.rest_url.length > 0)
                        $('#channel_web').html("<a target=\"_new\" href=\"http://" + JSONresult.rest_url + "\" ><img src=\"img/icon_www_on.png\" /></a>");
                    else
                        $('#channel_web').html("<img src=\"img/icon_www_off.png\" />");
                    // ¿TIENE FACEBOOK?					
                    if(JSONresult.rest_facebook.toString().length > 0)
                        $('#channel_facebook').html("<a target=\"_new\" href=\"http://facebook.com/" + JSONresult.rest_facebook + "\" ><img src=\"img/icon_facebook_on.png\" /></a>");
                    else
                        $('#channel_facebook').html("<img src=\"img/icon_facebook_off.png\" />");
                    // ¿TIENE TWITTER?
                    if(JSONresult.rest_twitter.toString().length > 0)
                        $('#channel_twitter').html("<a target=\"_new\" href=\"http://twitter.com/" + JSONresult.rest_twitter + "\" ><img target=\"_new\" href=\"" + JSONresult.rest_twitter + "\" src=\"img/twitter_logo_on.png\" /></a>");
                    else
                        $('#channel_twitter').html("<img src=\"img/twitter_logo_off.png\" />");
                    // REEMPLAZO DE LA DESCRIPCION DE LA CIUDAD
					$("#txt_city_categorias").html(JSONresult.ds_rest_city);
					$("#txt_city_posicion").html(JSONresult.ds_rest_city);
					
                    // MAPA
                    var map;
                    var service;
                    var infowindow;
                
                    var resto_point = new google.maps.LatLng(JSONresult.rest_latitude,JSONresult.rest_longitude);
                    
                    map = new google.maps.Map(document.getElementById('map'), {
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        center: resto_point,
                        scrollwheel: false,
                        zoom: 16
                        });
                    infowindow = new google.maps.InfoWindow();
                    
                    
                    var marker = new google.maps.Marker({
                          position: resto_point,
                          map: map,
                          icon: 'img/marker_resto.png' 
                      });
                    
                    // CONSULTO RESTAURANTES CERCANOS
                    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php echo $_GET['id_resto']; ?>&type=IRESTAURANTING_CERCANOS', 
                        function(JSONresult) {
                            var htmlStr = "<table class=\"tabla\">";
                            htmlStr += "<tr><td></td><td></td><td class=\"titulo_tabla\">Indicador iR</td></tr>";
                            for(var i=0; (i < JSONresult.length) && (i < 10); i++){
                                // Se crean los makers
                                var marker = new google.maps.Marker({
                                    position: new google.maps.LatLng(JSONresult[i].latitude,JSONresult[i].longitude),
                                    map: map,
                                    icon: 'img/marker_' + (i+1) + '.png' 
                                });
                                
                                if(i % 2 == 1)  // fila impar
                                    htmlStr += "<tr class=\"fila_resto_impar\">";
                                else
                                    htmlStr += "<tr>";
                                htmlStr += "<td class=\"cell_posicion\"><img src=\"img/marker_" + (i+1) + ".png\" /></td>";
                                htmlStr += "<td>" + JSONresult[i].description  + "</td>";
                                htmlStr += "<td class=\"cell_valoracion\">" + JSONresult[i].scoring + "</td>";	
                                htmlStr +=  "</tr>";
                        
                            }
                            htmlStr += "</table>";
                            $('#list_restos').html(htmlStr);
                        }
                    );
                    
                    // CONSULTO PEOR Y MEJOR DIA
                    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php echo $_GET['id_resto']; ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=BEST_AND_WORST', 
                        function(JSONresult) {
							var resumen_best="";
							var resumen_worst="";
                            for(var i=0; (i < JSONresult.length); i++){
                                strMessage = JSONresult[i].message;
                                
                                if(JSONresult[i].best_worst == 'BEST_DAY'){
									resumen_best = JSONresult[i].message;
									resumen_best = resumen_best.replace('#',"<span class=\"highlight_resumen_categoria\">" + JSONresult[i].date + "</span>");
								}
                                else{
									resumen_worst = JSONresult[i].message;
									resumen_worst = resumen_worst.replace('#',"<span class=\"highlight_resumen_categoria\">" + JSONresult[i].date + "</span>");
								}
                            }
							
							if(resumen_best != resumen_worst){
								htmlOutput = "<div class=\"tabla_resumen_global\" style=\"margin-bottom:15px;margin-top:15px;\">";
                    			htmlOutput += "<div class=\"celda_resumen_global\">";
                        		htmlOutput += "<div id=\"resumen_best\" class=\"resumen_global\">";
								htmlOutput += resumen_best;
                            	htmlOutput += "</div>";
                         		htmlOutput += "</div>";
                    			htmlOutput += "</div>";
                    			htmlOutput += "<div id=\"table_worst\" class=\"tabla_resumen_global\" style=\"margin-bottom:15px\">";
                    			htmlOutput += "<div class=\"celda_resumen_global\">";
                        		htmlOutput += "<div id=\"resumen_worst\" class=\"resumen_global\">";
								htmlOutput += resumen_worst;
                    			htmlOutput += "</div>";
                         		htmlOutput += "</div>";
                    			htmlOutput += "</div>";
								
							}
							else{
								htmlOutput = "<div class=\"tabla_resumen_global_equal\"  >";
                    			htmlOutput += "<div class=\"celda_resumen_global\">";
                        		htmlOutput += "<div class=\"resumen_global\">";
                    			htmlOutput += resumen_worst;
                    			htmlOutput += "</div>";
                         		htmlOutput += "</div>";
                    			htmlOutput += "</div>";
								
							}
							$("#column_best_worst").html(htmlOutput);
                        }
                    );
                    
                }
        );
    });
    
	$(function () {
        $.getJSON('metrics/fresh_scoring.php?id_resto=' + id_resto + '&type=IRESTAURANTING_MODULES', function(JSONresult) {
			if(JSONresult.foursquare == 1) {
				$("#canales_comprados").css("display","inline-block");
				load_foursquare_module();
			}
		});
	});
	
	function load_foursquare_module(){
		$("#foursquare_module_left").css("display","inline-block");
		$("#foursquare_module_right").css("display","inline-block");
		$.getJSON('metrics/fresh_scoring.php?id_resto=<?php echo $_GET['id_resto']; ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=FOURSQUARE_STATS', function(JSONresult) {
            
            var chart; // global				
        
            var options = {
                chart: {
                    renderTo: 'foursquare_checkins_by_day',
                    zoomType: 'xy'
                },
                title: {
                    enabled: false,
                    text: null
                },
                subtitle: {
                    text: null
                },
                exporting: {
                    enabled: false
                },
                xAxis:{
                    title:'',
                    tickInterval: 5,
                    categories:[]
                },
                yAxis: [{ // Primary yAxis
					min: 0,
					allowDecimals:false,
                    labels: {
                        format: ' {value}',
                        style: {
                            color: '#666'
                        }
                    },
                    title: {
                        text: 'Valoración',
                        style: {
                            color: '#666'
                        }
                    }
                }, { // Secondary yAxis
					allowDecimals:false,
                    title: {
                        text: 'Checkins',
                        style: {
                            color: '#FBB040'
                        }
                    },
                    labels: {
                        format: ' {value}',
                        style: {
                            color: '#FBB040'
                        }
                    },
                    opposite: true
                }],
				
                tooltip: {
                    shared: true
                },
                series:[{
                    showInLegend: false, 
                    name: 'Checkins',
                    color: '#FBB040',
                    type: 'column',
                    yAxis: 1,
                    tooltip: {
                        valueSuffix: ' checkins'
                    }
        
                }, {
                    showInLegend: false, 
                    name: 'Valoración',
                    color: '#666',
                    type: 'spline',
                    tooltip: {
                        valueSuffix: ' '
                    }
                }]
            };
            
			if(JSONresult[2].length > 0){
            	options.xAxis.categories = JSONresult[0];
            	options.series[0].data = JSONresult[2];
            	options.series[1].data = JSONresult[1];
            
            	chart = new Highcharts.Chart(options);
			}
			else{
				$("#foursquare_checkins_by_day").html("<img src=\"img/no_foursquare_checkins_by_day.png\" />");
			}
           	
            if(JSONresult[3].name.length > 0){
				var htmlTw = "";
			    htmlTw = "<div class=\"container_fan_picture\"><a href=\"" + JSONresult[3].url_user + "\">";
                htmlTw += "<img src=\"" + JSONresult[3].url_photo + "\" width=\"50px\" height=\"50px\" />";
                htmlTw += "</a></div><div class=\"container_fan_texto\">" + JSONresult[3].name + "</div>";
				
                $('#container_foursquare_mayor').html(htmlTw);
            	$('#img_foursquare_channel').attr("href",JSONresult[3].url_foursquare);
				
			}
			
        }
        );
	}
	
    $(function () {
        $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
            echo $_GET['id_resto'];
                ?>&type=CHANNELS_PRESENCE', function(JSONresult) {
                    for(var i=0; i < JSONresult.length; i++){
                        if(JSONresult[i].id_parameter == 'PRESENCE_ATRAPALO')
                            if(JSONresult[i].presence==1)
                                $('#channel_atrapalo').html("<a target=\"_new\" href=\"" + JSONresult[i].url + "\" ><img src=\"img/icon_atrapalo_on.png\" /></a>");
                            else
                                $('#channel_atrapalo').html("<img src=\"img/icon_atrapalo_off.png\" />");
                            
                        if(JSONresult[i].id_parameter == 'PRESENCE_YELP')
                            if(JSONresult[i].presence==1)
                                $('#channel_yelp').html("<a target=\"_new\" href=\"" + JSONresult[i].url + "\" ><img src=\"img/icon_yelp_on.png\"  /></a>");
                            else
                                $('#channel_yelp').html("<img src=\"img/icon_yelp_off.png\" />");
                            
                        if(JSONresult[i].id_parameter == 'PRESENCE_SALIR')
                            if(JSONresult[i].presence==1)
                                $('#channel_salir').html("<a target=\"_new\" href=\"" + JSONresult[i].url + "\" ><img src=\"img/icon_salir_on.png\" /></a>");
                            else
                                $('#channel_salir').html("<img src=\"img/icon_salir_off.png\" />");
                            
                        if(JSONresult[i].id_parameter == 'PRESENCE_TENEDOR')
                            if(JSONresult[i].presence==1)
                                $('#channel_eltenedor').html("<a target=\"_new\" href=\"" + JSONresult[i].url + "\" ><img src=\"img/icon_eltenedor_on.png\" /></a>");
                            else
                                $('#channel_eltenedor').html("<img src=\"img/icon_eltenedor_off.png\" />");
                            
                        if(JSONresult[i].id_parameter == 'PRESENCE_TRIPADVISOR')
                            if(JSONresult[i].presence==1)
                                $('#channel_tripadvisor').html("<a target=\"_new\" href=\"" + JSONresult[i].url + "\" ><img src=\"img/icon_tripadvisor_on.png\" /></a>");
                            else
                                $('#channel_tripadvisor').html("<img src=\"img/icon_tripadvisor_off.png\" />");
                            
                        if(JSONresult[i].id_parameter == 'PRESENCE_RESTALO')
                            if(JSONresult[i].presence==1)
                                $('#channel_restalo').html("<a target=\"_new\" href=\"" + JSONresult[i].url + "\" ><img src=\"img/icon_restalo_on.png\" /></a>");
                            else
                                $('#channel_restalo').html("<img src=\"img/icon_restalo_off.png\" />");
                    }
                }
        );
    });
            
    $(function () {
        $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
            echo $_GET['id_resto'];
                ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=IRESTAURANTING_SCORING', function(JSONresult) {
                    var chart; // global				
        
                    var options = {
                        chart: {
                            renderTo: 'container_grafica'
                        },
                        title: {
                            text: null
                        },
                        subtitle: {
                            text: null
                        },
                        exporting: {
                            enabled: false
                        },
                        xAxis: {
                            tickInterval: 5,
                            labels: {
                                formatter: function() {
                                    return this.value; // clean, unformatted number for year
                                }
                            }
                        },
                        
                        yAxis:{
							min: 0,
							max: 10,
                            title: {
                                text: null
                            },
                            labels: {
                                formatter: function() {
                                    return this.value;
                                }
                            }
                        },
                        tooltip: {
                            pointFormat: '<b>{point.y:,.1f}</b> en {series.name}'
                        },
                        plotOptions: {
                            area: {
                                
                                marker: {
                                    enabled: false,
                                    symbol: 'circle',
                                    radius: 2,
                                    states: {
                                        hover: {
                                            enabled: true
                                        }
                                    }
                                }
                            },
                            series: {
                                lineWidth: 3
                            }
                        },
                        series:[{
                            color: '#FBB040',
                            showInLegend: true, 
                            "name": "Indicador Global",
							type: "area",							
                            data: []
                        },
						{                           
                            showInLegend: true, 
                            "name": "Presencia",
							visible : false,
							type: "line",							
							marker: {
                                    enabled: false,
                                    symbol: 'circle',
                                    radius: 2,
                                    states: {
                                        hover: {
                                            enabled: true
                                        }
                                    }
                                },
                            data: []
                        },
						{                           
                            showInLegend: true, 
                            "name": "Opiniones",
							visible : false,
							type: "line",
							marker: {
                                    enabled: false,
                                    symbol: 'circle',
                                    radius: 2,
                                    states: {
                                        hover: {
                                            enabled: true
                                        }
                                    }
                                },
                            data: []
                        },
						{                           
                            showInLegend: true, 
                            "name": "Actividad",
							visible : false,
							type: "line",
							marker: {
                                    enabled: false,
                                    symbol: 'circle',
                                    radius: 2,
                                    states: {
                                        hover: {
                                            enabled: true
                                        }
                                    }
                                },
                            data: []
                        }]
                    };
                    
                    //yData = options.series[0].data; //Array to store data for y column
                    //xData = options.xAxis.categories; //Array to store data for x column
                    
                    //xDataObj = JSONresult[0];
                    //yDataObj = JSONresult[1];
                    /*
                    for(var key in xDataObj){
                        alert
                        xData.push(xDataObj[key]);
                        
                    }*/
                    options.xAxis.categories = JSONresult[0];
                    options.series[0].data = JSONresult[1];
					options.series[1].data = JSONresult[2];
					options.series[2].data = JSONresult[3];
					options.series[3].data = JSONresult[4];
                    /*
                    for(var key in yDataObj){
                        yData.push(yDataObj[key]);
                        
                    }
                    */
                    chart = new Highcharts.Chart(options);
                }
        );
    });
    
    
    $(function () {
    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
        echo $_GET['id_resto'];
            ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=SCORING_BY_CATEGORIES', function(JSONresult) {
            
            var chart; // global				
        
            var options = {
                chart: {
                    renderTo: 'graph_ranking_category',
                    defaultSeriesType: 'bar'
                },
                title: {
                    enabled: false,
                    text: null
                },
                subtitle: {
                    text: null
                },
                exporting: {
                    enabled: false
                },
                xAxis:{
                    title:'',
                    categories:[]
                },
                yAxis:{
                    title:{
                        text:null
                    }
                },
                tooltip: {
                            pointFormat: '<b>{point.y:,.1f}</b> en {series.name}'
                        },
                series:[{
                    color: 'black',
                    showInLegend: false, 
                    "name": "iRestauranting Scoring",
                    data: []
                }]
            };
            
            yData = options.series[0].data; //Array to store data for y column
            xData = options.xAxis.categories; //Array to store data for x column

            xDataObj = JSONresult[0];
            yDataObj = JSONresult[1];

            for(var key in xDataObj){
                xData.push(xDataObj[key]);
                
            }

            for(var key in yDataObj){
                yData.push(yDataObj[key]);
                
            }
            
            chart = new Highcharts.Chart(options);
            
            var strCat = "";
            var basta = false;
            for(var i=0; (i < JSONresult[2].length); i++){
                if(!basta)
                    strCat = strCat + JSONresult[2][i].desc + ", ";
            
                if(strCat.length >= 58 && !basta) {
                    strCat = strCat.substr(0,strCat.length - JSONresult[2][i].desc.length - 2);
                    basta = true;
                }
            }
            if(basta)
                strCat += " ...";
            else
                strCat = strCat.substr(0,strCat.length - 2);
            
            $("#ini_txt_city_categorias").html("Los mejores restaurantes de ");
			$("#end_txt_city_categorias").html(" en la/s categoría/s: <span style=\"font-size:15px\"><i>" + strCat + "</i>");
        }
        );
                
    });
    
    $(function () {
    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
        echo $_GET['id_resto'];
            ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=REVIEWS_BY_CATEGORY', function(JSONresult) {
            
            var chart; // global				
        
            var options = {
                chart: {
                    renderTo: 'reviews_by_category'
                },
                title: {
                    enabled: false,
                    text: null
                },
                exporting: {
                    enabled: false
                },
                subtitle: {
                    text: null,
                    x: -20
                },
                xAxis: {
                    tickInterval: 5,
                    categories: []
                },
                yAxis: {
                    title:{
                            text:null
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                },
				tooltip: {
                            pointFormat: '<b>{point.y:,.1f}</b> en {series.name}'
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                series: [{
                    name: 'Comida',
                    data: []
                }, {
                    name: 'Servicio',
                    data: []
                }, {
                    name: 'Atmósfera',
                    data: []
                }, {
                    name: 'Calidad/Precio',
                    data: []
                }]
            };
            
            options.xAxis.categories = JSONresult[0];
            options.series[0].data = JSONresult[1];
            options.series[1].data = JSONresult[2];
            options.series[2].data = JSONresult[3];
            options.series[3].data = JSONresult[4];
            
            chart = new Highcharts.Chart(options);
        }
        );
                
    });
    
    
    
    $(function () {
    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
        echo $_GET['id_resto'];
            ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=REVIEWS_SENTIMENTAL', function(JSONresult) {
            
            var chart; // global				
        
            var options = {
                chart: {
                    renderTo: 'reviews_sentimental',
                    type: 'column'
                },
                title: {
                    enabled: false,
                    text: null
                },
                exporting: {
                    enabled: false
                },
                xAxis: {
					tickInterval: 5,
                    categories: []
                },
                yAxis: {
                    min: 0,
					allowDecimals: false,
                    title:{
                            text:null
                    },
                    stackLabels: {
                        enabled: true,
                        style: {
                            fontWeight: 'bold',
                            color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                        }
                    }
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                plotOptions: {
                    column: {
                        stacking: 'normal',
                        dataLabels: {
                            enabled: true,
                            color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                        }
                    },
                    series: {
                        dataLabels:{
                            enabled:true,
                            formatter:function(){
                                if(this.y > 0)
                                    return this.y;
                            }
                        },
						point: {
							events: {
								click: function() {	
									hash = 'DT_' + JSONresult[0][this.x] + '/13';
									click_tab('tab_opiniones','<?php echo $_GET['id_resto']; ?>',hash);
									/*								
									$.magnificPopup.open({
									  items: {
										src: '<div class="white-popup-thanks"><div class="resumen_indicador_graph"><span class=\"texto_span_orange_23"\>Ver opiniones</span><br/><br/>Esta funcionalidad se encuentra disponible solo en la versión <b>Premium</b> de iRestauranting</div></div>', 
										type: 'inline',
										midClick: true 
									  }
									});					
									*/				
								}
							}
						}
                    }					
                },
                series: [{
                    name: 'Positivas',
                    color: '#008000',
                    data: []
                }, {
                    name: 'Negativas',
                    color: '#ff0000',
                    data: []
                }, {
                    name: 'Neutras',
                    color: '#fbb040',
                    data: []
                }]
            };
            
            options.xAxis.categories = JSONresult[0];
            options.series[0].data = JSONresult[1];
            options.series[1].data = JSONresult[2];
            options.series[2].data = JSONresult[3];
			
			var hayOpiniones = false;
			for(var i=0; i < JSONresult[1].length; i++){
				if(JSONresult[1][i] > 0)
					hayOpiniones = true;
			}
			for(var i=0; i < JSONresult[2].length && !hayOpiniones; i++){
				if(JSONresult[2][i] > 0)
					hayOpiniones = true;
			}
			for(var i=0; i < JSONresult[3].length && !hayOpiniones; i++){
				if(JSONresult[3][i] > 0)
					hayOpiniones = true;
			}
			if(hayOpiniones)
            	chart = new Highcharts.Chart(options);
			else
				$("#reviews_sentimental").html("<img src=\"img/no_opiniones_sentimental.png\" />");
        }
        );
                
    });
    
    
    $(function () {
    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
        echo $_GET['id_resto'];
            ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=FACEBOOK_STATS', function(JSONresult) {
            
            var chart; // global				
        
            var options = {
                chart: {
                    renderTo: 'facebook_post_by_day',
                    zoomType: 'xy'
                },
                title: {
                    enabled: false,
                    text: null
                },
                subtitle: {
                    text: null
                },
                exporting: {
                    enabled: false
                },
                xAxis:{
                    title:'',
                    tickInterval: 5,
                    categories:[]
                },
                yAxis: [{ // Primary yAxis
                    labels: {
                        format: ' {value}',
                        style: {
                            color: '#666'
                        }
                    },
                    title: {
                        text: 'Fans',
                        style: {
                            color: '#666'
                        }
                    }
                }, { // Secondary yAxis
                    title: {
                        text: 'Posts',
                        style: {
                            color: '#FBB040'
                        }
                    },
                    labels: {
                        format: ' {value}',
                        style: {
                            color: '#FBB040'
                        }
                    },
                    opposite: true
                }],
                tooltip: {
                    shared: true
                },
                
                series:[{
                    showInLegend: false, 
                    name: 'Posts',
                    color: '#FBB040',
                    type: 'column',
                    yAxis: 1,
                    tooltip: {
                        valueSuffix: ' posts'
                    }
        
                }, {
                    showInLegend: false, 
                    name: 'Fans',
                    color: '#666',
                    type: 'spline',
                    tooltip: {
                        valueSuffix: ' fans'
                    }
                }]
            };
            
			if(JSONresult[2].length > 0){
            	options.xAxis.categories = JSONresult[0];
            	options.series[0].data = JSONresult[1];
            	options.series[1].data = JSONresult[2];
            
            	chart = new Highcharts.Chart(options);
			}
			else{
				$("#facebook_post_by_day").html("<img src=\"img/no_facebook_stats.png\" />");
			}
            
            if(JSONresult[2].length > 0){
            	$('#facebook_num_likes').html("<b>" + (JSONresult[3].num_likes != null ? JSONresult[3].num_likes : "0") + "</b> Likes en posts");
            	$('#facebook_num_comments').html("<b>" + (JSONresult[3].num_comments != null ? JSONresult[3].num_comments : "0")  + "</b> Comentarios en posts");
            	$('#facebook_num_shares').html("<b>" + (JSONresult[3].num_shares != null ? JSONresult[3].num_shares : "0") + "</b> Posts compartidos");
			}
			else{
				$("#facebook_stats_likes").html("<img src=\"img/no_facebook_likes.png\" />");
			}
            
        }
        );
                
    });
    
    
    $(function () {
    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
        echo $_GET['id_resto'];
            ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=TWITTER_STATS', function(JSONresult) {
            
            var chart; // global				
        
            var options = {
                chart: {
                    renderTo: 'twitter_mentions_by_day',
                    //defaultSeriesType: 'bar'
                    zoomType: 'xy'
                },
                title: {
                    enabled: false,
                    text: null
                },
                subtitle: {
                    text: null
                },
                exporting: {
                    enabled: false
                },
                xAxis:{
                    title:'',
                    tickInterval: 5,
                    categories:[]
                },
                yAxis: [{ // Primary yAxis
                    labels: {
                        format: ' {value}',
                        style: {
                            color: '#666'
                        }
                    },
                    title: {
                        text: 'Followers',
                        style: {
                            color: '#666'
                        }
                    }
                }, { // Secondary yAxis
                    title: {
                        text: 'Mentions',
                        style: {
                            color: '#FBB040'
                        }
                    },
                    labels: {
                        format: ' {value}',
                        style: {
                            color: '#FBB040'
                        }
                    },
                    opposite: true
                }],
                tooltip: {
                    shared: true
                },
                
                series:[{
                    showInLegend: false, 
                    name: 'Mentions',
                    color: '#FBB040',
                    type: 'column',
                    yAxis: 1,
                    tooltip: {
                        valueSuffix: ' mentions'
                    }
        
                }, {
                    showInLegend: false, 
                    name: 'Followers',
                    color: '#666',
                    type: 'spline',
                    tooltip: {
                        valueSuffix: ' followers'
                    }
                }]
            };
            
            if(JSONresult[2].length > 0){
				options.xAxis.categories = JSONresult[0];
				options.series[0].data = JSONresult[1];
				options.series[1].data = JSONresult[2];
				
				chart = new Highcharts.Chart(options);
			}
			else{
				$("#twitter_mentions_by_day").html("<img src=\"img/no_twitter_stats.png\" />");
				$("#twitter_followers").html("<img src=\"img/no_twitter_followers.png\" />");
			}
        }
        );
                
    });
    
    // USUARIOS DE TWITTER MAS ACTIVOS
    $(function () {
        $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
            echo $_GET['id_resto'];
                ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=TWITTER_USERS', function(JSONresult) {
                    var htmlTw = "";
					if(JSONresult.length == 0)
						$("#twitter_followers").html("<img src=\"img/no_twitter_followers.png\" />");
                    for(var i=0; i < JSONresult.length; i++){
                        htmlTw = "<div class=\"container_fan_picture\"><a href=\"https://twitter.com/" + JSONresult[i].screen_name + "\">";
                        htmlTw += "<img src=\"" + JSONresult[i].URL + "\" width=\"50px\" height=\"50px\" />";
                        htmlTw += "</a></div><div class=\"container_fan_texto\">" + JSONresult[i].name + "</div>";
                        $('#container_fan' + (i+1)).html(htmlTw);
                    }
					
                    //$('#scoring').text(JSONresult.irest_scoring);
                    //$('#adress_resto').text(JSONresult.address.toUpperCase());
                    //$('#num_ranking').text(JSONresult.num_ranking);
                }
        );
    });
    
    
    
    $(function () {
    $.getJSON('metrics/fresh_scoring.php?id_resto=<?php
        echo $_GET['id_resto'];
            ?>&intervalo=' + intervalo_fechas.toUpperCase() + '&type=REVIEWS_RANKING', function(JSONresult) {
            
            var chart; // global				
        
            var options = {
                chart: {
                    renderTo: 'ranking_reviews',
                    defaultSeriesType: 'bar'
                },
                title: {
                    enabled: false,
                    text: null
                },
                subtitle: {
                    text: null
                },
                exporting: {
                    enabled: false
                },
                xAxis:{
                    title:'',
					allowDecimals: false,
                    categories:[]
                },
                yAxis:{					
                    title:{
                        text:null
                    },
					allowDecimals: false
                },
                series:[{
                    color: '#FBB040',
                    showInLegend: false, 
                    "name": "Número de opiniones en los últimos 30 días",
                    data: []
                }]
            };
            
            yData = options.series[0].data; //Array to store data for y column
            xData = options.xAxis.categories; //Array to store data for x column

            xDataObj = JSONresult[0];
            yDataObj = JSONresult[1];

            for(var key in xDataObj){
                xData.push(xDataObj[key]);
                
            }
			var hayOpiniones = false;
			var mayorQueDiez = false;
            for(var key in yDataObj){
				if(yDataObj[key]>0)
					hayOpiniones = true;
				if(yDataObj[key]>10)
					mayorQueDiez = true;
                yData.push(yDataObj[key]);
                
            }
		
            if(hayOpiniones){
				if (options.series.length > 0) {
					
					chart = new Highcharts.Chart(options);
					if(!mayorQueDiez){						
						chart.yAxis[0].setExtremes(0,10);								
					}
				}
			}
			else{
				
				$("#ranking_reviews").html("<img src=\"img/no_opiniones.png\" />");
			}
        }
        );
                
    });

    
    </script>
    <script src="js/highcharts.js"></script>
    <script src="js/highcharts-more.js"></script>
    <script src="js/modules/exporting.js"></script>
    <script src="js/tabs.js"></script>
    <!-- Magnific Popup core JS file -->
    <script src="js/jquery.magnific-popup.js"></script> 
    
    <script type="text/javascript">
            
			$("#submitButtonId").click(function() {
				
				
				var url = "contact/contact_form.php"; // the script where you handle the form input.
			
				$.ajax({
					   type: "POST",
					   url: url,
					   data: $("#form_contact").serialize(), // serializes the form's elements.
					   success: function(data)
					   {
						  $.magnificPopup.open({
							  items: {
								src: '<div class="white-popup-thanks"><div class="resumen_indicador_graph">Muchas gracias por contactarnos.<br/><br/>Sus comentarios serán analizados por el equipo de iRestauranting</div></div>', 
								type: 'inline',
								midClick: true 
							  }
							});
						   
						 
					   }
					 });
			
				return false; // avoid to execute the actual submit of the form.
			});
			
           
			// Carga del popup del contact form
			$('#contact_form_link').magnificPopup({ 
			  type:'inline',
  			  midClick: true 
			});
			
			// Carga del popup del contact form
			$('#contact_form_link2').magnificPopup({ 
			  type:'inline',
  			  midClick: true 
			});
			
			
			
    </script>
    <script type="text/javascript">
	function ccAddAnalytics(){
		$.getScript('http://www.google-analytics.com/ga.js', function() { 
			var GATracker = _gat._createTracker('UA-42707380-1');
			GATracker._trackPageview(); 
		} );
	}; 
	</script> 
	<script src="js/cookieControl-6.2.min.js" type="text/javascript"></script>	
    <script type="text/javascript">//<![CDATA[
      cookieControl({
          t: {
              title: '<p>Este sitio utiliza cookies. Para más información vea la <a target="_blank" href="cookies.html">Política de Privacidad</a>.</p>',
              intro: '<p>Algunas de las cookies son fundamentales para que el sitio web funcione correctamente y que otras plataformas nos ayuden a mejor de acuerdo al uso que se le da al sitio web.</p>',
              full:'<p>These cookies are set when you submit a form, login or interact with the site by doing something that goes beyond clicking some simple links.</p><p>We also use some non-essential cookies to anonymously track visitors or enhance your experience of this site. If you\'re not happy with this, we won\'t set these cookies but some nice features on the site may be unavailable.</p><p>To control third party cookies, you can also <a class="ccc-settings" href="browser-settings" target="_blank">adjust your browser settings.</a></p><p>By using our site you accept the terms of our <a href="http://www.irestauranting.com/cookies.html">Privacy Policy</a>.</p>'
          },
          position:CookieControl.POS_LEFT,
          style:CookieControl.STYLE_TRIANGLE,
          theme:CookieControl.THEME_LIGHT, // light or dark
          startOpen:true,
          autoHide:7000,
          subdomains:true,
          protectedCookies: [], //list the cookies you do not want deleted, for example ['analytics', 'twitter']
          apiKey: 'e5aa1f7af100b4a21ef9fc41b7687f749cd28a8e',
          product: CookieControl.PROD_FREE,
          consentModel: CookieControl.MODEL_INFO,
          onAccept:function(){ccAddAnalytics()},
          onReady:function(){},
          onCookiesAllowed:function(){ccAddAnalytics()},
          onCookiesNotAllowed:function(){}
          });
       //]]>
    </script>
</body>

</html>